/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package clases;

import entidades.Supervisor;
import java.util.List;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.context.FacesContext;
import negocio.SupervisorInterface;

/**
 *
 * @author BATAQUERO
 */
@ManagedBean
public class ListaSupervisoresBean {
    
    @EJB
    private SupervisorInterface supervisorInterface;
    private List<Supervisor> supervisor;
    private Supervisor supervisorSelected;
    
    @PostConstruct
    public void init(){
        cargarSupervisores();
    }
    
    public void cargarSupervisores(){
        supervisor = supervisorInterface.listarSupervisores();
    }

    public void actualizarSupervisorUniversitario(Supervisor supervisor){
        try{
            supervisorInterface.actualizarSupervisor(supervisor);
            FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("El estado del supervisor ha sido cambiado satisfactoriamente."));
        } catch (Exception e) {
            FacesMessage facesMessage = new FacesMessage("Error");
            FacesContext.getCurrentInstance().addMessage(null, facesMessage);
            e.printStackTrace();
        }
    }
    
    public List<Supervisor> getSupervisor() {
        return supervisor;
    }

    public void setSupervisor(List<Supervisor> supervisor) {
        this.supervisor = supervisor;
    }

    public Supervisor getSupervisorSelected() {
        return supervisorSelected;
    }

    public void setSupervisorSelected(Supervisor supervisorSelected) {
        this.supervisorSelected = supervisorSelected;
    }
      
}
